package edu.scu.declaresys.dao.impl;

import java.util.Date;

import org.hibernate.criterion.Restrictions;

import edu.scu.declaresys.dao.DAOFactory;
import edu.scu.declaresys.dao.intr.ILoginLogDAO;
import edu.scu.declaresys.dao.util.Depth;
import edu.scu.declaresys.exception.ExecuteException;
import edu.scu.declaresys.util.PageList;
import edu.scu.declaresys.vo.LoginLog;

public class LoginLogDAOImpl extends GeneralDAOImpl<LoginLog> implements ILoginLogDAO
{
	public LoginLogDAOImpl()
	{
		super(LoginLog.class);
	}

	@Override
	public PageList<LoginLog> findByTime(String propertyName, Date startTime, Integer pageNum, Integer amtPerPage) throws ExecuteException
	{
		return super.findByProperty(Restrictions.ge(propertyName, startTime), Depth.ONE, pageNum, amtPerPage, LoginLog.T_TIME, true);
	}

	@Override
	protected void fillReference(LoginLog vo, int depth)
			throws ExecuteException
	{
		vo.setUser(DAOFactory.createUserDAO().findByPropertyUnique(LoginLog.T_USER_NAME, vo.getUserName(), depth - 1));
	}
	
	
}
